package com.ruoyi.personnel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.personnel.domain.TeachingBook;
import com.ruoyi.personnel.mapper.TeachingBookMapper;
import com.ruoyi.personnel.service.ITeachingBookService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 教程编写Service业务层处理
 *
 * @author ruoyi
 * @date 2021-03-05
 */
@Service
public class TeachingBookServiceImpl extends ServiceImpl<TeachingBookMapper, TeachingBook> implements ITeachingBookService {

    @Override
    public List<TeachingBook> queryList(TeachingBook teachingBook) {
        LambdaQueryWrapper<TeachingBook> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(teachingBook.getName())){
            lqw.like(TeachingBook::getName ,teachingBook.getName());
        }
        if (StringUtils.isNotBlank(teachingBook.getJobNumber())){
            lqw.eq(TeachingBook::getJobNumber ,teachingBook.getJobNumber());
        }
        if (StringUtils.isNotBlank(teachingBook.getPersonnelId())){
            lqw.eq(TeachingBook::getPersonnelId ,teachingBook.getPersonnelId());
        }
        if (teachingBook.getOfficeId() != null){
            lqw.eq(TeachingBook::getOfficeId ,teachingBook.getOfficeId());
        }
        if (StringUtils.isNotBlank(teachingBook.getOfficeName())){
            lqw.like(TeachingBook::getOfficeName ,teachingBook.getOfficeName());
        }
        if (StringUtils.isNotBlank(teachingBook.getBookName())){
            lqw.like(TeachingBook::getBookName ,teachingBook.getBookName());
        }
        if (StringUtils.isNotBlank(teachingBook.getBookSpecifications())){
            lqw.eq(TeachingBook::getBookSpecifications ,teachingBook.getBookSpecifications());
        }
        if (StringUtils.isNotBlank(teachingBook.getPress())){
            lqw.eq(TeachingBook::getPress ,teachingBook.getPress());
        }
        if (StringUtils.isNotBlank(teachingBook.getPublishDate())){
            lqw.eq(TeachingBook::getPublishDate ,teachingBook.getPublishDate());
        }
        if (StringUtils.isNotBlank(teachingBook.getEditorLevel())){
            lqw.eq(TeachingBook::getEditorLevel ,teachingBook.getEditorLevel());
        }
        if (StringUtils.isNotBlank(teachingBook.getRanking())){
            lqw.eq(TeachingBook::getRanking ,teachingBook.getRanking());
        }
        if (StringUtils.isNotBlank(teachingBook.getStatus())){
            lqw.eq(TeachingBook::getStatus ,teachingBook.getStatus());
        }
        return this.list(lqw);
    }
}
